package com.example.expedition.data.modules.finance.service;

import com.example.expedition.data.common.utils.UUIDUtils;
import com.example.expedition.data.modules.finance.dao.BalanceMapper;
import com.example.expedition.data.modules.finance.entity.Balance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * 描述：
 *
 * @author zengyz
 * @date 2018/8/22 15:57
 */
@Service
@Transactional(rollbackFor = {Exception.class, RuntimeException.class})
public class BalanceService {

    @Autowired
    private BalanceMapper balanceMapper;

    public int add(Balance balance) throws Exception{
        balance.setId(UUIDUtils.getUUID32());
        balance.setCreateTime(new Date());
        balance.setUpdateTime(new Date());
        balance.setVersion(0L);
        return balanceMapper.insert(balance);
    }
}
